import { updateAutoSureReceiveOrder } from '@/api/network'
import { Ref, ref } from 'vue'

export default function (ids: Ref<Array<string>>) {
  // 批量更新服务商接单策略加载
  const updateAutoSureReceiveOrderLoading = ref(false)

  // 是否自动接单：false-手动确认，true-自动接单
  const autoSureReceiveOrder = ref(true)

  // 批量更新服务商接单策略方法
  const updateAutoSureReceiveOrderFn = async () => {
    updateAutoSureReceiveOrderLoading.value = true
    const res = await updateAutoSureReceiveOrder(autoSureReceiveOrder.value, ids.value)
    updateAutoSureReceiveOrderLoading.value = false
    return res.data as { code: number; data: object; message: string; success: boolean }
  }

  return {
    autoSureReceiveOrder,
    updateAutoSureReceiveOrderLoading,
    updateAutoSureReceiveOrderFn,
  }
}
